﻿using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.ConsumableMaterials;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.Devices;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.MedicineDistribution;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.MedicineInventory;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.PendingPrescription;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.PrescriptionCheck;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.ProgramInf;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.ResultItemInf;
using B.S.Sterilizationcenter.Writer.API.Appliaction.Commends.Yjb.ResultItemInfoss;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Sterilizationcenter.Writer.API.Controllers.YJB
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class YjbController : ControllerBase
    {
        private readonly IMediator mediator;

        public YjbController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 耗材添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddConsum(AddConsumableMaterialCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 耗材删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelConsum(DelConsumableMaterialCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 耗材修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]

        public async Task<ApiResult<int>> UpdateConsum(UpdateConsumableMaterialCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 树形图添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddConsumTree(AddConsumTypeCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 添加设备
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddCX(AddProgramInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 删除设备
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelCX(DelProgramInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改设备
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateCX(UpdateProgramInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 添加设备
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddSB(AddDeviceCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除设备
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelSB(DelDeviceCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改设备
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateSB(UpdateDeviceCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 添加检查信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<ApiResult<int>> AddJC(AddResultItemInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelJC(DelResultItemInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateJC(UpdateResultItemInfoCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 添加结果值
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddJG(AddResultItemInfosCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPut]
        public async Task<ApiResult<int>> DelJG(DelResultItemInfosCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateJG(UpdateResultItemInfosCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }

        #region 处方查看表操作
        /// <summary>
        /// 添加处方查看记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddPrescriptionCheck(AddPrescriptionCheckCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 删除处方查看记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelPrescriptionCheck(DelPrescriptionCheckCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 修改处方查看记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdatePrescriptionCheck(UpdatePrescriptionCheckCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion

        #region 已打印未发药表操作
        /// <summary>
        /// 添加已打印未发药记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddMedicineDistribution(AddMedicineDistributionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 删除已打印未发药记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelMedicineDistribution(DelMedicineDistributionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 修改已打印未发药记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateMedicineDistribution(UpdateMedicineDistributionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion

        #region 查看已发药品表操作
        /// <summary>
        /// 添加已发药品记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddMedicineInventory(AddMedicineInventoryCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 删除已发药品记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelMedicineInventory(DelMedicineInventoryCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 修改已发药品记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateMedicineInventory(UpdateMedicineInventoryCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion

        #region 未打印处方表操作
        /// <summary>
        /// 添加未打印处方记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddPendingPrescription(AddPendingPrescriptionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 删除未打印处方记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DelPendingPrescription(DelPendingPrescriptionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 修改未打印处方记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdatePendingPrescription(UpdatePendingPrescriptionCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion
    }
}
